package de.haw.HESextern.Transport;

import java.util.ArrayList;
import java.util.List;

public class TransportTabCacheMock implements TransportTabCache {

	private List<TransportComplex> cache;
	
	public TransportTabCacheMock() {
		cache = new ArrayList<TransportComplex>();
		cache.add(new TransportComplex(new TransportId(1), true));
		cache.add(new TransportComplex(new TransportId(2), true));
		cache.add(new TransportComplex(new TransportId(3), true));
		cache.add(new TransportComplex(new TransportId(4), false));
		cache.add(new TransportComplex(new TransportId(5), true));
	}

	@Override
	public List<TransportComplex> getTransportsByStatus(Boolean status) {
		List<TransportComplex> result = new ArrayList<TransportComplex>();
		for(TransportComplex e : cache) {
			if(e.getDelivered().equals(status)) {
				result.add(e);
			}
		}
		return result;
	}

	@Override
	public List<TransportComplex> getCache() {
		return new ArrayList<TransportComplex>(cache);
	}

	@Override
	public TransportComplex getTransportById(TransportId id) {
		for(TransportComplex e : cache) {
			if(e.getId().equals(id)) {
				return e;
			}
		}
		return null;
	}
	
}
